/*
 * ImageReferencerDialog.java
 *
 * Created on July 1, 2005, 11:58 AM
 */

package ika.gui;

import ika.geo.*;

/**
 *
 * @author  jenny
 */
public class ImageReferencerDialog extends javax.swing.JDialog {
    
    /** Creates new form ImageReferencerDialog */
    public ImageReferencerDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        imageReferencerPanel = new ika.gui.ImageReferencerPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Reference Image");
        setModal(true);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        getContentPane().add(imageReferencerPanel, java.awt.BorderLayout.CENTER);

        pack();
    }
    // </editor-fold>//GEN-END:initComponents
    
    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        if (this.imageReferencerPanel.askUserForAborting())
            this.dispose();
    }//GEN-LAST:event_formWindowClosing
    
    public void referenceImage(GeoImage geoImage, GeoSet destinationGeoSet) {
        if (geoImage == null)
            throw new IllegalArgumentException();
        
        geoImage.setSelectable(false);
        
        this.imageReferencerPanel.setImage(geoImage);
        this.imageReferencerPanel.setDestinationGeoSet(destinationGeoSet);
        this.setVisible(true);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ImageReferencerDialog(new javax.swing.JFrame(), true).setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private ika.gui.ImageReferencerPanel imageReferencerPanel;
    // End of variables declaration//GEN-END:variables
    
}
